<h2>Pending Requirements</h2>
<hr>
<div id="warpaccordion">
		<div id="accordion">
		<?php 
			$req = $this->req;
			foreach($req as $key => $value){
				echo '<h3><a class="title" href="#"> Requirement_id: '.$value["requirement_id"].'</a></h3>';
				echo '<div class="ui-widget ui-corner-all">';
				if($value['agent_id']){
					echo '<b>AGENT_REG_ID:</b><span class="agent">'.$value["agent_id"].'</span>';	
				}
				else{
					echo '<b>NAME: </b><span class="guest">'.$value["name"].'</span> <br>';
					echo '<b>CONTACT: </b><span class="guest">'.$value["contact_no"].'</span><br>';
					if($value["email"]){
						echo '<b>EMAIL: </b><span class="guest">'.$value["email"].'</span><br>';
					}
				}
				echo '<p style="padding-left:20px">';
				switch($value["category_id"]){
					case "COM":
							echo '<br><b>Category:</b> Commerial'.'<br>';
							break;
					case "RES":
							echo '<br><b>Category:</b> Residential'.'<br>';
							break;
					case "RRL":
							echo '<br><b>Category:</b> Rural'.'<br>';
							break;
					case "IND":
							echo '<br><b>Category:</b> Industrial'.'<br>';
							break;
				}
				echo '<b>Looking for:</b> '.$value["looking_for"].'<br>';
				echo '<b>Enquiry:</b> '.$value["enquiry"].'<br>';
				echo '</p>';
			//	echo '<button name="acknowledge" onclick="javascript:acknowledge('.$value['requirement_id'].');">Acknowledge</button>';
				echo '</div>';
			} 
		?>
		</div><!-- End accordion -->
	</div><!-- End warpaccordion -->

<script type="text/javascript">
var urlAcknowledge = "<?php echo $this->url(array('module'=>'admin','controller' => 'requirement', 'action' => 'acknowledge'))?>";
$(function() {
	$( "#accordion" ).accordion();
});

function acknowledge(req_id) {
	$.ajax({
        url : urlAcknowledge,
        data : {'req_id': req_id},
        success: function(jStatus){
        	setTimeout(function(){
              	window.location.reload();
              	},1700);
          } 
        ,
            error: function(response) {
          	  $('#errorBox').text(response.responseText).parent().show();
                console.log(response);
                }
    });
}


</script>
<style>
.title{
	color:gray;
}
.name .agent{
	color:red;
}
</style>